package com.example.tijian_doctor_backend.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.tijian_doctor_backend.dto.CiReportDTO;
import com.example.tijian_doctor_backend.pojo.Orders;
import com.example.tijian_doctor_backend.result.Result;
import com.example.tijian_doctor_backend.service.CiReportService;
import com.example.tijian_doctor_backend.service.OrdersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author: bong~
 * @description: TODO
 * @date: 2024/6/23 14:53
 * @version: 1.0
 */
@RestController
@Slf4j
@RequestMapping("/ciReport")
@Api(tags ="报告接口")
@CrossOrigin("*")
public class CiReportController {


    @Autowired
    private CiReportService ciReportService;

    @Autowired
    private OrdersService ordersService;

    @ApiOperation("创建报告模板")
    @PostMapping("/createReportTemplate")
    public Result createReportTemplate(@RequestBody Map<String,Object> params){

        Integer orderId= (Integer) params.get("orderId");
        Integer smId =(Integer) params.get("smId");

        QueryWrapper<Orders> queryWrapper=new QueryWrapper<Orders>()
                .eq("orderId",orderId)
                .eq("smId",smId);
        Orders orders=ordersService.getOne(queryWrapper);

        if(orders==null){
            return Result.error("出错了");
        }


        return Result.success();


    }


    @ApiOperation("检查报告")
    @PostMapping("/listCiReport")
    public Result listCiReport(@RequestParam Integer orderId){


        List<CiReportDTO> list=ciReportService.listCiReport(orderId);

        return Result.success(list);




    }
}
